package com.github.wxpay.sdk;

import com.fbs.wowo.util.common.Property;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class WXOpenConfig extends WXPayConfig {

    // app支付appid
    public static final String WX_PAY_APP_ID        = "wx9d4023e1f4e8b0c9";
    // 微信 开发密钥
    public static final String WX_PAY_KEY           = "76394a9a00b85c632365b31751e1935c";
    // 微信商户号
    public static final String WX_PAY_MCH_ID        = "1519509651";
    // 微信app secert
    public static final String WX_AppSecret         = "76394a9a00b85c632365b31751e1935c";

    private static byte[] certData;
    static {
        InputStream certStream = null;
        try {
//            certData = new byte[(int) file.length()];
            certData = new byte[2876];
            certStream = Property.class.getClassLoader().getResourceAsStream("dangwowo.p12");;
            certStream.read(certData);
            for (byte certDatum : certData) {
                System.out.print(certDatum);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取 App ID
     *
     * @return App ID
     */
    @Override
    public String getAppID() {
        return WX_PAY_APP_ID;
    }

    /**
     * 获取 Mch ID
     *
     * @return Mch ID
     */
    @Override
    public String getMchID() {
        return WX_PAY_MCH_ID;
    }

    /**
     * 获取 API 密钥
     *
     * @return API密钥
     */
    @Override
    public String getKey() {
        return WX_PAY_KEY;
    }

    /**
     * 获取商户证书内容
     *
     * @return 商户证书内容
     */
    @Override
    public InputStream getCertStream() {
        ByteArrayInputStream certBis = new ByteArrayInputStream(certData);
        return certBis;
    }

    /**
     * 获取WXPayDomain, 用于多域名容灾自动切换
     *
     * @return
     */
    @Override
    public IWXPayDomain getWXPayDomain() {
        return new WXPayDomain();
    }
}
